<template>
  <div>
    <el-dialog title="货道设置" :visible.sync="outerVisible" width="60%">
      <!-- 外层内容 -->
      <!-- 外title -->
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple-dark outTitle">
            <div>货道行数:6</div>
            <div>货道列数:10</div>
            <div>货道容量(个):10</div>
            <el-button type="primary" @click="innerVisible = true"
              >智能排货</el-button
            >
          </div>
        </el-col>
      </el-row>
      <!-- 外body -->
      <el-scrollbar>
      <el-row :gutter="20">
        <el-col :span="5" v-for="item in channelOne" :key="item.channelId">
          <div class="item">
            <div class="code">{{ item.channelCode }}</div>
            <div class="sku" v-if="item.sku">
              <img :src="item.sku.skuImage" />
              <div>{{ item.sku.skuName }}</div>
            </div>
            <div class="sku" v-else>
              <img src="" />
              <div>暂无商品</div>
            </div>
            <div>
              <!-- button -->
              <el-button
                  class="add_buttom"
                  type="primary"
                  @click="addSku(item)"
                  >添加</el-button
                >
                <el-button
                  class="delete_buttom"
                  type="danger"
                  :disabled="!item.sku"
                  >删除</el-button
                >
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5" v-for="item in channelTwo" :key="item.channelId">
          <div class="item">
            <div class="code">{{ item.channelCode }}</div>
            <div class="sku" v-if="item.sku">
              <img :src="item.sku.skuImage" />
              <div>{{ item.sku.skuName }}</div>
            </div>
            <div class="sku" v-else>
              <img src="" />
              <div>暂无商品</div>
            </div>
            <div>
              <!-- button -->
              <el-button
                  class="add_buttom"
                  type="primary"
                  @click="addSku(item)"
                  >添加</el-button
                >
                <el-button
                  class="delete_buttom"
                  type="danger"
                  :disabled="!item.sku"
                  >删除</el-button
                >
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5" v-for="item in channelThree" :key="item.channelId">
          <div class="item">
            <div class="code">{{ item.channelCode }}</div>
            <div class="sku" v-if="item.sku">
              <img :src="item.sku.skuImage" />
              <div>{{ item.sku.skuName }}</div>
            </div>
            <div class="sku" v-else>
              <img src="" />
              <div>暂无商品</div>
            </div>
            <div>
              <!-- button -->
              <el-button
                  class="add_buttom"
                  type="primary"
                  @click="addSku(item)"
                  >添加</el-button
                >
                <el-button
                  class="delete_buttom"
                  type="danger"
                  :disabled="!item.sku"
                  >删除</el-button
                >
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5" v-for="item in channelFour" :key="item.channelId">
          <div class="item">
            <div class="code">{{ item.channelCode }}</div>
            <div class="sku" v-if="item.sku">
              <img :src="item.sku.skuImage" />
              <div>{{ item.sku.skuName }}</div>
            </div>
            <div class="sku" v-else>
              <img src="" />
              <div>暂无商品</div>
            </div>
            <div>
              <!-- button -->
              <el-button
                  class="add_buttom"
                  type="primary"
                  @click="addSku(item)"
                  >添加</el-button
                >
                <el-button
                  class="delete_buttom"
                  type="danger"
                  :disabled="!item.sku"
                  >删除</el-button
                >
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5" v-for="item in channelFive" :key="item.channelId">
          <div class="item">
            <div class="code">{{ item.channelCode }}</div>
            <div class="sku" v-if="item.sku">
              <img :src="item.sku.skuImage" />
              <div>{{ item.sku.skuName }}</div>
            </div>
            <div class="sku" v-else>
              <img src="" />
              <div>暂无商品</div>
            </div>
            <div>
              <!-- button -->
              <el-button
                  class="add_buttom"
                  type="primary"
                  @click="addSku(item)"
                  >添加</el-button
                >
                <el-button
                  class="delete_buttom"
                  type="danger"
                  :disabled="!item.sku"
                  >删除</el-button
                >
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5" v-for="item in channelSix" :key="item.channelId">
          <div class="item">
            <div class="code">{{ item.channelCode }}</div>
            <div class="sku" v-if="item.sku">
              <img :src="item.sku.skuImage" />
              <div>{{ item.sku.skuName }}</div>
            </div>
            <div class="sku" v-else>
              <img src="" />
              <div>暂无商品</div>
            </div>
            <div>
              <!-- button -->
              <el-button
                  class="add_buttom"
                  type="primary"
                  @click="addSku(item)"
                  >添加</el-button
                >
                <el-button
                  class="delete_buttom"
                  type="danger"
                  :disabled="!item.sku"
                  >删除</el-button
                >
            </div>
          </div>
        </el-col>
      </el-row>
      </el-scrollbar>
      <el-dialog
        width="50%"
        title="内层 Dialog"
        :visible.sync="innerVisible"
        append-to-body
      >
        <!-- 内层内容 -->
      </el-dialog>
      <div slot="footer" class="dialog-footer">
        <el-button @click="outerVisible = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getChannelList } from '@/api/zhang/equipment'
export default {
  data () {
    return {
      outerVisible: true,
      innerVisible: false,
      // channelList: [],
      channelOne: [],
      channelTwo: [],
      channelThree: [],
      channelFour: [],
      channelFive: [],
      channelSix: []
    }
  },
  methods: {
    async getChannelList () {
      const res = await getChannelList('01000001')
      // console.log(res)
      // this.channelList = res
      this.channelOne = res.filter((item) => item.channelCode.startsWith('1'))
      // console.log(this.channelOne)
      this.channelTwo = res.filter((item) => item.channelCode.startsWith('2'))
      this.channelThree = res.filter((item) =>
        item.channelCode.startsWith('3')
      )
      this.channelFour = res.filter((item) => item.channelCode.startsWith('4'))
      this.channelFive = res.filter((item) => item.channelCode.startsWith('5'))
      this.channelSix = res.filter((item) => item.channelCode.startsWith('6'))
    },
    // 删除商品
    deleteType (item) {
      item.sku = null
    },
    // 添加商品
    addSku (item) {

    }
  },
  created () {
    // console.log(this.channelList)
    this.getChannelList()
  }
}
</script>
<style lang="scss" scoped>
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.outTitle {
  display: flex;
  height: 56px;
  line-height: 56px;
  background-color: #f3f6fb;
  div {
    min-width: 100px;
    margin-left: 50px;
    margin-right: 15px;
  }
  .el-button {
    // align-items: center;
    min-width: 80px;
    height: 36px;
    margin-left: 30%;
    margin-top: 1.3%;
  }
}
.el-scrollbar {
        width: 814px;
        height: 384px;
        margin: 0 auto;
        // 滑动滚轮隐藏
        .el-scrollbar__wrap {
          overflow-x: hidden;
        }
        .is-horizontal {
          display: none;
        }
        .rightActive {
          transform: translateX(-830px);
        }
        .leftActive {
          transform: translateX(0px);
        }
.el-row{
  display: flex;
  // overflow: hidden;
  .el-col {
            margin-right: -5px;
          }
}}
.item {
  position: relative;
  margin-bottom: 20px;
  width: 150px;
  height: 180px;
  text-align: center;
  box-shadow: 0 2px 4px 0 rgb(0 0 0 / 6%);
  .code {
    position: absolute;
    top: 10px;
    left: 0;
    width: 43px;
    height: 23px;
    line-height: 23px;
    border-radius: 0 10px 10px 0;
    font-size: 12px;
    color: #fff;
    background: #829bed;
  }
  .sku {
    height: 135px;
    background-color: #f6f7fb;
    padding-top: 16px;
    img {
      width: 84px;
      height: 78px;
      border-radius: 4px;
      margin-bottom: 10px;
    }
  }
}
</style>
